package com.songcha.module_home.ui.adapter

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import com.songcha.module_home.bean.HomeCateBean
import com.songcha.module_home.ui.fragment.cate.HomeCateFragment
import com.songcha.module_home.ui.fragment.homehome.HomeHomeFragment

class HomeTabAdapter(fm:FragmentManager,val list: MutableList<HomeCateBean.DataBean>):FragmentStatePagerAdapter(fm){
    override fun getCount(): Int {
       return list.size
    }

    override fun getItem(position: Int): Fragment {
       if(position==0){
           return HomeHomeFragment()
       }else{
           val bundle=Bundle()
           bundle.putInt("cate_id",list[position].id)
           val frag=HomeCateFragment()
           frag.arguments=bundle
           return frag
       }
    }

    override fun getPageTitle(position: Int): CharSequence? {
       return list[position].customName
    }

}